package com.it2297.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;

import com.it2297.controller.CompanyController;
import javax.swing.JTextArea;

public class CompanyViewCompanyDetails extends JFrame {

	private JPanel contentPane;
	private JTextField tb_name;  
    private JTextField tb_email;
    private JTextField tb_phone;
    final CompanyController cct= new CompanyController(this);   
    private JButton btnview;
    private JTextArea tb_address;
    private JTextArea tb_desc;
    private JPanel panel;
	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ViewCompanyDetailsTest frame = new ViewCompanyDetailsTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}*/

    public String getCompanyName(){ 	  
        return tb_name.getText().toString();
    }
	public void setCompanyName(String companyName){	
	        tb_name.setText(companyName);
	}
	public void setEmail(String email){	
	        tb_email.setText(email);	
	}	
	public void setAddress(String address){	
	        tb_address.setText(address);	
	}	
	public void setPhone(String phone){	
	        tb_phone.setText(phone);	
	}	
	public void setDescription(String description){	
	        tb_desc.setText(description);	
	} 
	
	/**
	 * Create the frame.
	 */
	public CompanyViewCompanyDetails() {
			 //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			 setBounds(100, 100, 740, 560);
			 contentPane = new JPanel();
			 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
			 setContentPane(contentPane);
			 contentPane.setLayout(null);

			 JLabel lblCompanyRegistration = new JLabel("Company Details");			 
	         lblCompanyRegistration.setFont(new Font("Times New Roman", Font.BOLD, 35));
	         lblCompanyRegistration.setBounds(10, 11, 704, 70);
	         getContentPane().add(lblCompanyRegistration);
	        
	         JLabel lblCompanyName = new JLabel("Company Name:");
	         lblCompanyName.setFont(new Font("Tahoma", Font.BOLD, 14));
	         lblCompanyName.setBounds(10, 92, 188, 24);
	         getContentPane().add(lblCompanyName);

	         JLabel lblNewLabel = new JLabel("Company Email:");
	         lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
	         lblNewLabel.setBounds(10, 391, 188, 24);
	         getContentPane().add(lblNewLabel);
	         
	         JLabel lblNewLabel_1 = new JLabel("Company Address:");
	         lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 14));
	         lblNewLabel_1.setBounds(10, 127, 188, 24);
	         getContentPane().add(lblNewLabel_1);
	        
	         JLabel lblNewLabel_2 = new JLabel("Company Phone Number:");
	         lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 14));
	         lblNewLabel_2.setBounds(10, 354, 188, 24);
	         getContentPane().add(lblNewLabel_2);
	         
	         JLabel lblNewLabel_3 = new JLabel("Company Description:");
	         lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 14));
	         lblNewLabel_3.setBounds(10, 242, 188, 24);
	         getContentPane().add(lblNewLabel_3);
	         
	         tb_name = new JTextField();
	         tb_name.setEditable(false);
	         tb_name.setBounds(208, 93, 321, 26);
	         getContentPane().add(tb_name);
	         tb_name.setColumns(10);
       
	         tb_email = new JTextField();
	         tb_email.setEditable(false);
	         tb_email.setBounds(208, 392, 262, 26);
	         getContentPane().add(tb_email);
	         tb_email.setColumns(10);	         

	         tb_phone = new JTextField();
	         tb_phone.setEditable(false);
	         tb_phone.setBounds(208, 355, 145, 26);
	         getContentPane().add(tb_phone);
	         tb_phone.setColumns(10);
    
	         btnview = new JButton("View");
	         btnview.setFont(new Font("Tahoma", Font.BOLD, 15));
	         btnview.addActionListener(new ActionListener() {
	         	public void actionPerformed(ActionEvent arg0) {
	         	cct.viewCompanyDetails();
	         	btnview.setEnabled(false);
	         	}
	         });
	         btnview.setBounds(539, 92, 85, 28);
	         getContentPane().add(btnview);
	         
	         JButton btnBackToSearch = new JButton("Back to search");
	         btnBackToSearch.addActionListener(new ActionListener() {
	         	public void actionPerformed(ActionEvent arg0) {
	         		closeWindow();
	         	}
	         });
	         btnBackToSearch.setFont(new Font("Tahoma", Font.BOLD, 15));
	         btnBackToSearch.setBounds(208, 447, 155, 27);
	         getContentPane().add(btnBackToSearch);
	         
	         tb_address = new JTextArea();
	         tb_address.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
	         tb_address.setEditable(false);
	         tb_address.setBounds(208, 129, 282, 100);
	         contentPane.add(tb_address);
	         
	         tb_desc = new JTextArea();
	         tb_desc.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
	         tb_desc.setEditable(false);
	         tb_desc.setBounds(208, 244, 439, 100);
	         contentPane.add(tb_desc);
	         
	         panel = new JPanel();
	         panel.setBackground(Color.WHITE);
	         panel.setBounds(0, 0, 724, 522);
	         contentPane.add(panel);
	}

	public void closeWindow()
	{
		this.dispose();
	}
	
}
